﻿
@{
    Layout = null;
}

<link href="~/layer-v3.1.1/layer-v3.1.1/layer/theme/default/layer.css" rel="stylesheet" />
<link href="~/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/layer-v3.1.1/layer-v3.1.1/layer/layer.js"></script>
<script src="~/layui/layui.all.js"></script>
<!--add dialog start-->
<div class="site-text site-block">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="UserName" id="UserName" required lay-verify="required" placeholder="学生姓名" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别：</label>
            <div class="layui-input-block">
                <input type="radio" name="Sex" value="男" title="男" checked>
                <input type="radio" name="Sex" value="女" title="女">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">电话：</label>
            <div class="layui-input-block">
                <input type="text" name="Phone" id="Phone" required lay-verify="required" placeholder="联系方式" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">爱好：</label>
            <div class="layui-input-block">
                <input type="text" name="Hobby" id="Hobby" required lay-verify="required" placeholder="个人爱好" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述：</label>
            <div class="layui-input-block">
                <textarea name="Description" id="Description" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<!--add dialog end-->

<script>
    layui.use('form', function(){
        var form = layui.form;
        form.render(); //更新全部


        //监听提交
        form.on('submit(formDemo)', function(data){
            //layer.msg(JSON.stringify(data.field));
            $.ajax({
                async: true,
                dataType: 'json',
                type: 'post',
                url: "@Url.Action("AddUserInfo","OperationApi")",
                data:data.field,
                success:function(res) {
                    //layer.msg(res);
                    console.log(res);
                    if (res.code == 0) {//successfully
                        layer.confirm(res.resultMsg, {
                            icon:1,
                            btn: ["我知道了"],
                            yes: function (index) {
                                parent.location.href = "@Url.Action("Index")"; 
                                parent.layer.closeAll();//关闭全部
                            }
                        });

                    } else {
                        layer.msg(res.resultMsg);
                    }
                }
            });
            return false;
        });
    });
</script>
